//
//  CardInfoModel.m
//  Shengzhuli
//
//  Created by FXGuo on 17/3/29.
//  Copyright © 2017年 kamangkeji. All rights reserved.
//

#import "CardInfoModel.h"

@implementation CardInfoModel

- (instancetype)initWithDict:(NSDictionary *)dict
{
    if (self = [super init]) {
        self.name = dict[@"name"];
        self.cardPhone = dict[@"cardPhone"];
        self.company = dict[@"company"];
        self.position = dict[@"position"];
        self.companyProfile = dict[@"companyProfile"];
        self.location = dict[@"location"];
        self.detailedAddress = dict[@"detailedAddress"];
        self.emailAddress = dict[@"emailAddress"];
        self.status = [dict[@"status"] integerValue];
        self.shareUrl = dict[@"shareUrl"];
        /*  扫描获取别人名片
         demandResourcesMap =         (
         "\U96f6\U552e\U4e1a"
         );
         */
        
        NSArray *demandList = dict[@"demandResourcesMap"];
        if (demandList.count>0) {
            NSMutableArray *names = [NSMutableArray array];
            for (NSString *nameStr in demandList) {
                if (!nameStr) break;
                
                [names addObject:nameStr];
            }
            self.demIdNames = [names componentsJoinedByString:@"#"];
        }
        NSArray *proviedeList = dict[@"provideResourcesMap"];
        if (proviedeList.count>0) {
            NSMutableArray *names = [NSMutableArray array];
            for (NSString *nameStr in proviedeList) {
                if (!nameStr) break;
                [names addObject:nameStr];
            }
            self.proIdNames = [names componentsJoinedByString:@"#"];
        }
        
        /*  我的名片
         demandResourcesMap =         (
         {
         createDate = 1493004496000;
         id = 4211;
         industryName = "\U96f6\U552e\U4e1a";
         parentId = 4147;
         updateDate = 1493004496000;
         }
         )
         */
        /*
         NSArray *demandList = dict[@"demandResourcesMap"];
         if (demandList.count>0) {
         NSMutableArray *arr = [NSMutableArray array];
         NSMutableArray *ids = [NSMutableArray array];
         NSMutableArray *names = [NSMutableArray array];
         for (NSDictionary *dict in demandList) {
         if (!dict) break;
         SourceModel *model = [SourceModel objectWithDict:dict];
         [arr addObject:model];
         [ids addObject:@(model.ID)];
         [names addObject:model.industryName];
         }
         self.demandResourcesMap = arr;
         self.demandIds = ids;
         self.demIdNames = [names componentsJoinedByString:@"#"];
         }
         NSArray *proviedeList = dict[@"provideResourcesMap"];
         if (proviedeList.count>0) {
         NSMutableArray *arr = [NSMutableArray array];
         NSMutableArray *ids = [NSMutableArray array];
         NSMutableArray *names = [NSMutableArray array];
         for (NSDictionary *dict in proviedeList) {
         if (!dict) break;
         SourceModel *model = [SourceModel objectWithDict:dict];
         [arr addObject:model];
         [ids addObject:@(model.ID)];
         [names addObject:model.industryName];
         }
         self.provideResourcesMap = arr;
         self.provideIds = ids;
         self.proIdNames = [names componentsJoinedByString:@"#"];
         }
         *///按照返回类型是数组
        self.mobilePhone = dict[@"mobilePhone"];
        self.nickName = dict[@"nickName"];
        self.portraitUrl = dict[@"portraitUrl"];
    }
    return self;
}

+ (instancetype)objectWithDict:(NSDictionary *)dict
{
    return [[CardInfoModel alloc]initWithDict:dict];
}


@end
